
/*****************************************************************************
*******   VALUE TB - DO FILE FOR POOLING COST DATA ACROSS 5 COUNTRIES  *******
******************************************************************************/

*Created by: Sedona Sweeney, London School of Hygiene and Tropical Medicine


/* Prepping the folder for analysis and setting the file pathways to access the data entry files */


		clear all
		set more off
		*cap ssc install matrixtools

		cd "C:/Users/phpusswe/Dropbox/lshtm/Value TB/Value TB/Value TB/Data/3rd Review - Sedona & Anna" /// <-- change this directory when working from a different computer

		local c_date = c(current_date)
		local date_string = subinstr("`c_date'", " " , "", .)
		capture mkdir "Analysis/`date_string'"
		capture mkdir "Analysis/`date_string'/facilityfiles"
		capture mkdir "Graphs"
		putexcel clear
		 
		 		foreach c in  Ethiopia {  /* Georgia Ethiopia India  Georgia*/
				
		capture delete "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx"

		 
		local country = "`c'"  /// <-- change this to the appropriate country


*******************************************************************************
*******************************************************************************
*******   Creating standardized excel tables with unit cost estimates   *******
*******************************************************************************
*******************************************************************************


*************************************************************************************
/*Table 1 shows the unit cost per output, by top-down and bottom-up*/
*************************************************************************************

use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs_long_summary.dta", clear
		 
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		encode met_TDvBU, gen(tdbu)
		label var tdbu " "

		replace output = subinstr(output,"OP", "Outpatient",1)   
		replace output = subinstr(output,"IP", "Inpatient",1)   
		replace output = subinstr(output,"CM", "Community",1)   
		egen x = concat(output output_pop2)
		replace output = x if output_pop2 == "FLD" | output_pop2 == "SLD" | output_pop2 == "VOT" | output_pop2 == "Liquid media" |  output_pop2 == "Solid media" |  output_pop2 == "DSTB" | output_pop2 == "MDRTB"
		encode output, gen(output_t)
		label var output_t " "

		drop if substr(costtype, 1, 4) == "ohd_"
		encode costtype, gen(input)
		label var input " "

		keep if costtype == "total" & LCU_totalcost > 0 & servicestatistics > 0 & !missing(LCU_unitcost)
		
		putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Outputs Table 1 - USD) modify

		putexcel A1 = "Table 1 - Unit Cost per Output, top-down and bottom-up", nformat(text)
		putexcel J2 = "Top-down" C2 = "Bottom-up" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" , nformat(text) bold


		local row=5

		  
	 
		levelsof outputgroup, local(outputgroup)
		   foreach op2 of local outputgroup {
		   
			 preserve
		   keep if outputgroup == "`op2'"
		 
		 putexcel A`row' = "`op2'", nformat(text) bold
		 
		  sumat USD_unitcost if !missing(USD_unitcost), statistics(n mean sd ci min max) rowby(output_t) colby(tdbu) decimals((0,2,2,2))
			matrix tbl = r(sumat)
			putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)

			local row=(`row' + `= rowsof(tbl)' + 1)

			restore
		}


*************************************************************************************
/*Table 2 shows the unit cost per output, by input (grouped into four broad categories)*/
*************************************************************************************

use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs_long_summary.dta", clear
		 
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		encode met_TDvBU, gen(tdbu)
		label var tdbu " "

		replace output = subinstr(output,"OP", "Outpatient",1)   
		replace output = subinstr(output,"IP", "Inpatient",1)   
		replace output = subinstr(output,"CM", "Community",1)   
		egen x = concat(output output_pop2)
		replace output = x if output_pop2 == "FLD" | output_pop2 == "SLD" | output_pop2 == "VOT" | output_pop2 == "Liquid media" |  output_pop2 == "Solid media" |  output_pop2 == "DSTB" | output_pop2 == "MDRTB"
		encode output, gen(output_t)
		label var output_t " "

		drop if substr(costtype, 1, 4) == "ohd_"
		encode costtype, gen(input)
		label var input " "

		keep if costtype != "total" & LCU_totalcost > 0 & servicestatistics > 0 & !missing(LCU_unitcost)


	putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Outputs Table 2 - USD) modify


		putexcel A1 = "Table 1 - Unit Cost per Output, by input", nformat(text)
	
		putexcel C2 = "Bottom-up" C3 = "Capital" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J3 = "Consumables" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" Q3 = "Overhead" Q4 = "Count" R4 = "Mean" S4 = "Std Dev" T4 = "95% CI lb" U4 = "95% CI ub" V4 = "Min" W4 = "Max" X3 = "Staff" X4 = "Count" Y4 = "Mean" Z4 = "Std Dev" AA4 = "95% CI lb" AB4 = "95% CI ub" AC4 = "Min" AD4 = "Max" AE2 = "Top-down" AE3 = "Capital" AE4 = "Count" AF4 = "Mean" AG4 = "Std Dev" AH4 = "95% CI lb" AI4 = "95% CI ub" AJ4 = "Min" AK4 = "Max" AL3 = "Consumables" AL4 = "Count" AM4 = "Mean" AN4 = "Std Dev" AO4 = "95% CI lb" AP4 = "95% CI ub" AQ4 = "Min" AR4 = "Max" AS3 = "Overhead" AS4 = "Count" AT4 = "Mean" AU4 = "Std Dev" AV4 = "95% CI lb" AW4 = "95% CI ub" AX4 = "Min" AY4 = "Max" AZ3 = "Staff" AZ4 = "Count" BA4 = "Mean" BB4 = "Std Dev" BC4 = "95% CI lb" BD4 = "95% CI ub" BE4 = "Min" BF4 = "Max" , nformat(text) bold


 
	 local row=5


	  levelsof outputgroup, local(outputgroup)
	   foreach op2 of local outputgroup {
   
     preserve
	 

   keep if outputgroup == "`op2'"
 
 putexcel A`row' = "`op2'", nformat(text) bold
 
  sumat USD_inputs_uc_ if !missing(USD_inputs_uc_) & met_TDvBU == "BU", statistics(n mean sd ci min max) rowby(output_t) colby(input)  decimals((0,2,2,2))
	matrix tbl = r(sumat)
	putexcel B`row' = matrix(tbl), rownames nformat(number_d2)

   sumat USD_inputs_uc_ if !missing(USD_inputs_uc_) & met_TDvBU == "TD", statistics(n mean sd ci min max) rowby(output_t) colby(input)  decimals((0,2,2,2))
	matrix tbl = r(sumat)
	putexcel AE`row' = matrix(tbl), nformat(number_d2)
	
	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}



*************************************************************************************
/*Table 3 shows the unit cost per intervention, by top-down and bottom-up*/
*************************************************************************************

		putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Interventions Table 3 - USD) modify

		putexcel A1 = "Table 3 - Unit Cost per Intervention, top-down and bottom-up", nformat(text)
		putexcel J2 = "Top-down" C2 = "Bottom-up" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" , nformat(text) bold
		 
		 local row=5
		 
use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_patient.dta", clear
		
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		drop if int_class == "TB TREATMENT"
		label var int_detail_coded ""
		rename int_detail_coded idc

		 encode met_TDvBU, gen(tdbu)
			label var tdbu " "
			
			levelsof int_type, local(type)
		   foreach t of local type {
   
   preserve
    
   keep if int_type == "`t'"
   
 putexcel A`row' = "`t'", nformat(text) bold
 
  sumat tcost_USD if !missing(tcost_USD), statistics(n mean sd ci min max) rowby(idc) colby(tdbu) decimals((0,2,2,2))
	matrix tbl = r(sumat)
	
	if !missing(tcost_USD) {
	putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)
		   }

	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}


		**********************************************************************

		use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_treatcollapsed.dta", clear
		
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		encode met_TDvBU, gen(tdbu)
			label var tdbu " "
			
		encode int_detail, gen(int_detail_coded)
			label var int_detail_coded ""
			rename int_detail_coded idc
			 
		levelsof int_type, local(type)
		   foreach t of local type {
   
   preserve
    
   keep if int_type == "`t'"
   
 putexcel A`row' = "`t'", nformat(text) bold
 
  sumat tcost_USD if !missing(tcost_USD), statistics(n mean sd ci min max) rowby(idc) colby(tdbu) decimals((0,2,2,2))
	matrix tbl = r(sumat)
	
	if !missing(tcost_USD) {
	putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)
	}

	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}



*************************************************************************************
/*Table 1 shows the unit cost per output, by top-down and bottom-up*/
*************************************************************************************



		 use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs.dta", clear
		 	local row = 4

		 

		putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Outputs Table 1 - LCU) modify

		putexcel A1 = "Table 1 - Unit Cost per Output, top-down and bottom-up", nformat(text)
		putexcel J2 = "Top-down" C2 = "Bottom-up" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" , nformat(text) bold

		use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs_long_summary.dta", clear
		 
			keep if fc_country == "`c'" & met_FINvECON == "ECON"
			encode met_TDvBU, gen(tdbu)
			label var tdbu " "

		replace output = subinstr(output,"OP", "Outpatient",1)   
		replace output = subinstr(output,"IP", "Inpatient",1)   
		replace output = subinstr(output,"CM", "Community",1)   
		egen x = concat(output output_pop2)
		replace output = x if output_pop2 == "FLD" | output_pop2 == "SLD" | output_pop2 == "VOT" | output_pop2 == "Liquid media" |  output_pop2 == "Solid media" |  output_pop2 == "DSTB" | output_pop2 == "MDRTB"
		encode output, gen(output_t)
		label var output_t " "


		local row=5

		  keep if costtype == "total" & LCU_totalcost > 0 & servicestatistics > 0 & !missing(LCU_unitcost)
		  
	 
		levelsof outputgroup, local(outputgroup)
		   foreach op2 of local outputgroup {
		   
			 preserve
		   keep if outputgroup == "`op2'"
		 
		 putexcel A`row' = "`op2'", nformat(text) bold
		 
		  sumat LCU_unitcost if !missing(LCU_unitcost), statistics(n mean sd ci min max) rowby(output_t) colby(tdbu) decimals((0,2,2,2))
			matrix tbl = r(sumat)
			putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)

			local row=(`row' + `= rowsof(tbl)' + 1)

			restore
		}


*************************************************************************************
/*Table 2 shows the unit cost per output, by input (grouped into four broad categories)*/
*************************************************************************************

	putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Outputs Table 2 - LCU) modify


	putexcel A1 = "Table 1 - Unit Cost per Output, by input", nformat(text)
	
		putexcel C2 = "Bottom-up" C3 = "Capital" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J3 = "Consumables" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" Q3 = "Overhead" Q4 = "Count" R4 = "Mean" S4 = "Std Dev" T4 = "95% CI lb" U4 = "95% CI ub" V4 = "Min" W4 = "Max" X3 = "Staff" X4 = "Count" Y4 = "Mean" Z4 = "Std Dev" AA4 = "95% CI lb" AB4 = "95% CI ub" AC4 = "Min" AD4 = "Max" AE2 = "Top-down" AE3 = "Capital" AE4 = "Count" AF4 = "Mean" AG4 = "Std Dev" AH4 = "95% CI lb" AI4 = "95% CI ub" AJ4 = "Min" AK4 = "Max" AL3 = "Consumables" AL4 = "Count" AM4 = "Mean" AN4 = "Std Dev" AO4 = "95% CI lb" AP4 = "95% CI ub" AQ4 = "Min" AR4 = "Max" AS3 = "Overhead" AS4 = "Count" AT4 = "Mean" AU4 = "Std Dev" AV4 = "95% CI lb" AW4 = "95% CI ub" AX4 = "Min" AY4 = "Max" AZ3 = "Staff" AZ4 = "Count" BA4 = "Mean" BB4 = "Std Dev" BC4 = "95% CI lb" BD4 = "95% CI ub" BE4 = "Min" BF4 = "Max" , nformat(text) bold

		use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs_long_summary.dta", clear
	
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		drop if substr(costtype, 1, 4) == "ohd_"
		encode met_TDvBU, gen(tdbu)
		label var tdbu " "

		replace output = subinstr(output,"OP", "Outpatient",1)   
		replace output = subinstr(output,"IP", "Inpatient",1)   
		replace output = subinstr(output,"CM", "Community",1)   
		egen x = concat(output output_pop2)
		replace output = x if output_pop2 == "FLD" | output_pop2 == "SLD" | output_pop2 == "VOT" | output_pop2 == "Liquid media" |  output_pop2 == "Solid media" |  output_pop2 == "DSTB" | output_pop2 == "MDRTB"
		encode output, gen(output_t)
		label var output_t " "


				
	 encode costtype, gen(input)
		label var input " "
	 
	 local row=5

	  keep if costtype != "total" & LCU_totalcost > 0 & servicestatistics > 0 & !missing(LCU_unitcost)

	  levelsof outputgroup, local(outputgroup)
	   foreach op2 of local outputgroup {
   
     preserve
	 

   keep if outputgroup == "`op2'"
 
 putexcel A`row' = "`op2'", nformat(text) bold
 
  sumat LCU_inputs_uc_ if !missing(LCU_inputs_uc_) & met_TDvBU == "BU", statistics(n mean sd ci min max) rowby(output_t) colby(input)  decimals((0,2,2,2))
	matrix tbl = r(sumat)
	putexcel B`row' = matrix(tbl), rownames nformat(number_d2)

   sumat LCU_inputs_uc_ if !missing(LCU_inputs_uc_) & met_TDvBU == "TD", statistics(n mean sd ci min max) rowby(output_t) colby(input)  decimals((0,2,2,2))
	matrix tbl = r(sumat)
	
	if !missing(LCU_inputs_uc_) {
	putexcel AE`row' = matrix(tbl), nformat(number_d2)
	}
	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}



*************************************************************************************
/*Table 3 shows the unit cost per intervention, by top-down and bottom-up*/
*************************************************************************************

		putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Interventions Table 3 - LCU) modify

		putexcel A1 = "Table 3 - Unit Cost per Intervention, top-down and bottom-up", nformat(text)
		putexcel J2 = "Top-down" C2 = "Bottom-up" C4 = "Count" D4 = "Mean" E4 = "Std Dev" F4 = "95% CI lb" G4 = "95% CI ub" H4 = "Min" I4 = "Max" J4 = "Count" K4 = "Mean" L4 = "Std Dev" M4 = "95% CI lb" N4 = "95% CI ub" O4 = "Min" P4 = "Max" , nformat(text) bold
		 
		 local row=5
		 
		use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_patient.dta", clear
		
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		drop if int_class == "TB TREATMENT"
		label var int_detail_coded ""
		rename int_detail_coded idc

		 encode met_TDvBU, gen(tdbu)
			label var tdbu " "
			
			levelsof int_type, local(type)
		   foreach t of local type {
   
   preserve
    
   keep if int_type == "`t'"
   
 putexcel A`row' = "`t'", nformat(text) bold
 
  sumat tcost_LCU if !missing(tcost_LCU), statistics(n mean sd ci min max) rowby(idc) colby(tdbu) decimals((0,2,2,2))
	matrix tbl = r(sumat)
	
	if !missing(tcost_LCU) {
	putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)
		   }

	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}


		**********************************************************************

		use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_treatcollapsed.dta", clear
		
		keep if fc_country == "`c'" & met_FINvECON == "ECON"
		encode met_TDvBU, gen(tdbu)
			label var tdbu " "
			 
		encode int_detail, gen(int_detail_coded)
		label var int_detail_coded ""
		rename int_detail_coded idc
		
		levelsof int_type, local(type)
		   foreach t of local type {
   
   preserve
    
   keep if int_type == "`t'"
   
 putexcel A`row' = "`t'", nformat(text) bold
 
  sumat tcost_LCU if !missing(tcost_LCU), statistics(n mean sd ci min max) rowby(idc) colby(tdbu) decimals((0,2,2,2))
	matrix tbl = r(sumat)
	
	if !missing(tcost_LCU) {
	putexcel B`row' = matrix( tbl ), rownames nformat(number_d2)
	}

	local row=(`row' + `= rowsof(tbl)' + 1)

	restore
}



		 use "C:/Users/phpusswe/Dropbox/lshtm/VALUE TB/Value TB/Value TB/Data/3rd review - Sedona & Anna/Analysis/`date_string'/pooled dataset_outputs.dta", clear
		 	local row = 4

		 
		 
*************************************************************************************
/*Table 4 Methods */
*************************************************************************************


keep if fc_country == "`c'" &  & met_FINvECON == "ECON"
local country = "`c'"
keep if USD_totalcost > 0 

		replace output = subinstr(output,"OP", "Outpatient",1)   
		replace output = subinstr(output,"IP", "Inpatient",1)   
		replace output = subinstr(output,"CM", "Community",1)   
		egen x = concat(output output_pop2)
		replace output = x if output_pop2 == "FLD" | output_pop2 == "SLD" | output_pop2 == "VOT" | output_pop2 == "Liquid media" |  output_pop2 == "Solid media" |  output_pop2 == "DSTB" | output_pop2 == "MDRTB"
		encode output, gen(output_t)
		label var output_t " "


				foreach metvars of varlist met_stafftime_obs met_stafftime_int met_stafftime_tmst met_stafftime_ass met_equip_obs met_equip_int met_supp_obs met_supp_int {
					cap replace `metvars' = ".n" if `metvars' == ".NA" | `metvars' == "'.NA"
					cap destring `metvars', replace ignore(`"%"')
					} 
	
	putexcel set "Analysis/`date_string'/appendixtbls_`c'_`date_string'.xlsx", sheet(Methods Table 2) modify
	
	putexcel B3 = "Output" C3 = "Number facilities" D1 = "Staff time measurement methods" D2 = "Top-down" D3 = "Interview" E3 = "Timesheet"  F3 = "Assumption" G2 = "Bottom-up" G3 = "Observation" H3 = "Interview" I1 = "Equipment measurement methods" I2 = "Bottom-up" I3 = "Observation" J3 = "Interview" K1 = "Supplies measurement methods" K2 = "Bottom-up" K3 = "Observation" L3 = "Interview", nformat(text) bold
	

	levelsof outputgroup, local(outputgroup)
		   foreach op2 of local outputgroup {
		   	
		preserve
		keep if outputgroup == "`op2'"
		 
		 putexcel A`row' = "`op2'", nformat(text) bold	
			
		  sumat USD_unitcost if met_TDvBU == "BU", statistics(n) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel B`row' = matrix( tbl ), rownames nformat(number_d0)
			
			
		  sumat met_stafftime_int if met_TDvBU == "TD", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel D`row' = matrix( tbl ), nformat(number_d2)
			
		sumat met_stafftime_tmst if met_TDvBU == "TD", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel E`row' = matrix( tbl ), nformat(number_d2)
			
		sumat met_stafftime_ass if met_TDvBU == "TD", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel F`row' = matrix( tbl ), nformat(number_d2)

			
		sumat met_stafftime_obs if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel G`row' = matrix( tbl ), nformat(number_d2)	
		
		sumat met_stafftime_int if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel H`row' = matrix( tbl ), nformat(number_d2)	
			
		
		sumat met_equip_obs if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel I`row' = matrix( tbl ), nformat(number_d2)	
			
		sumat met_equip_int if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel J`row' = matrix( tbl ), nformat(number_d2)	
			
		
		sumat met_supp_obs if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel K`row' = matrix( tbl ), nformat(number_d2)	
			
		sumat met_supp_int if met_TDvBU == "BU", statistics(mean) rowby(output_t) full decimals((2))
			matrix tbl = r(sumat)
			putexcel L`row' = matrix( tbl ), nformat(number_d2)				
	
	local row=(`row' + `= rowsof(tbl)' + 1)
	restore
	
		   }
		   
 
 
				}
				
				